package com.bw.database.db

import androidx.room.DeleteColumn
import androidx.room.RenameColumn
import androidx.room.RenameTable
import androidx.room.migration.AutoMigrationSpec
import androidx.sqlite.db.SupportSQLiteDatabase


/**
 * 用户信息表升级,修改表名
 */
@RenameTable(
    fromTableName = "user_info_table",
    toTableName = "user_info"
)
class UserInfoAutoMigration : AutoMigrationSpec

/**
 * 先修改实体字段，再做升级配置，旧数据库中的字段名
 * 用户信息表升级,修改表字段
 */
@RenameColumn(
    tableName = "user_info_table",
    fromColumnName = "name",
    toColumnName = "user_name"
)
class UserInfoColumnAutoMigration : AutoMigrationSpec


/**
 * 删除表字段
 * 用户信息表升级,修改表字段
 */
@DeleteColumn(tableName = "user_info_table", columnName = "ctime")
class UserInfoDeleteColumnAutoMigration:AutoMigrationSpec{
    override fun onPostMigrate(db: SupportSQLiteDatabase) {
        super.onPostMigrate(db)
        //db.execSQL("")
        //重新操作sql语句
    }

}



